Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use changeCompilerHostLikeToUseCache in synchronizeHostData #48980

Merged
merged 6 commits into from
May 19, 2022

Conversation

amcasey
Copy link
Member

@amcasey amcasey commented May 6, 2022

...rather than the older, less thorough, HostCache. The main benefit is caching file and directory existence (and, especially, non-existence) which cuts mui project load time by 1-2% on my (Linux) box.

Alternative to #48942

@amcasey amcasey requested a review from sheetalkamat May 6, 2022 00:33
@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels May 6, 2022
Comment on lines 1383 to 1389
cachingInEffect = false;
compilerHost.getSourceFile = originalGetSourceFile;
compilerHost.readFile = originalReadFile;
compilerHost.fileExists = originalFileExists;
compilerHost.directoryExists = originalDirectoryExists;
compilerHost.createDirectory = originalCreateDirectory;
compilerHost.writeFile = originalWriteFile!;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having flag to see if caching is in effect, can we set compilerHost to undefined here and check that instead of flag to see if caching is in effect.

Suggested change
cachingInEffect = false;
compilerHost.getSourceFile = originalGetSourceFile;
compilerHost.readFile = originalReadFile;
compilerHost.fileExists = originalFileExists;
compilerHost.directoryExists = originalDirectoryExists;
compilerHost.createDirectory = originalCreateDirectory;
compilerHost.writeFile = originalWriteFile!;
compilerHost = undefined;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, missed this comment. I'm happy to give that a shot, but I found it pretty difficult to track the lifetime of compilerHost so I'm basically just taking your word for it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, though I personally prefer the version without the extra bangs.

@amcasey amcasey merged commit 5aa0053 into microsoft:main May 19, 2022
@amcasey amcasey deleted the HostCacheCleanup branch May 19, 2022 00:26
@andrewbranch
Copy link
Member

@amcasey this seems to have broken the twoslash runner—does this stack trace give you any clue as to how/why?

@amcasey
Copy link
Member Author

amcasey commented Jun 10, 2022

@andrewbranch What's twoslash and is that stack from the product code or from a tool?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants